< previous page page_285 next page >

Page 285
0285-01.jpg
Figure 12.33
Progress bars provide a visual indication of
how much of an operation has been completed.
Max and Min are the other properties that you need to set for the progress bar. They represent the maximum and minimum values allowed for the Value property. In the case of the thermometer, they represent the top and bottom of the temperature scale. For example, if you set the Min property to 0 and the Max property to 100, setting the Value property to 50 causes the progress bar to look half full.
The setting of the Max and Min properties can be any valid integer, though the Max property must always be greater than the Min property. You can set these properties to any values that make sense for your applications. Some examples are as follows:
In processing a database, set Min to 0 and Max to the number of records to be processed. As each record is processed, incrementing the Value property informs the users of the processing progress.
For a file download operation, you might set Max to the number of kilobytes or number of blocks in the file. One typical setting is a Min of 0 and a Max of 100 to represent the percentage of the file that has been transferred.
Updating the Progress Bar As Your Code Runs
The key to displaying the progress of an operation in the progress bar is setting the Value property. As your code runs through an operation, you periodically update the setting of the Value property. As you might expect, you often do so in a loop that performs a repetitive operation, as in the following code sample:
'In the following code, "rsMain" is a recordset
'that has already been opened and populated.
'"pbr" is the ProgressBar control.

pbr.Min = 0
rsMain.MoveLast
pbr.Max = rsMain.RecordCount
rsMain.MoveFirst
inCounter = 0

While Not rsMain.EOF
'Insert code to process record here
     inCounter = inCounter + 1
     pbr.Value = inCounter
     rsMain.MoveNext
Wend
Adding Video with the Animation Control
The Animation control provides you with an easy way to add animation to your programs. You use this control to play silent Audio Video Interleaved (AVI) clips. The AVI file format is basically a series of bitmaps that are shown in sequence to create the animation effect, similar to

 
< previous page page_285 next page >